home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / comm / ca29_3.zip / DD.CMD < prev    next >
OS/2 REXX Batch file  |  1992-08-28  |  3KB  |  120 lines

  1.     SET TTHRU OFF        ; Allow type ahead
  2. ;
  3. ; ----- Dialing directory list
  4. ;    Commenced: 8/92 R.McG
  5. ; ----------------------------------------------------------------
  6. ;    Note: This script searches the current directory for *.DIR
  7. ;    files, and displays a menu of the results.
  8. ; ----------------------------------------------------------------
  9. ;
  10. ;    First, draw a box
  11. ;
  12.     LEGEND " Select a dialing directory"
  13.     ON ESCAPE GOSUB EXIT
  14. ;
  15. ;    Start by opening a window
  16. ;
  17.     GOSUB Window        ; Open a window
  18. ;
  19. ;    Now, look for a keypress
  20. ;
  21.     FFIRST "*.DIR"          ; Search for directories
  22.     IF FAILED GOTO EndLoop    ; Exit if none found
  23.     N10 = 0         ; Index of files found
  24.     SET FLAG(0) OFF     ; Flag -> pass1/pass2
  25. ;
  26. ;    Build the menu
  27. ;
  28. Loop:
  29.     IF N10 GE 20 GOTO Keyget
  30.     FNEXT S10[N10]        ; Read next directory
  31.     IF FAILED GOTO EndLoop
  32.  
  33.     N0 = N10\10        ; Row # 0-9
  34.     IF N10 LT 10
  35.        ATSAY N0+2,15 (defa) S10[N10]
  36.     ELSE
  37.        ATSAY N0+2,45 (defa) S10[N10]
  38.        ENDIF
  39.     INC N10
  40.     GOTO Loop        ; And loop
  41. ;
  42. ;    End of loop.  After pass on current subdir, if no
  43. ;    *.DIR's are found, try on the COM-AND= subdir...
  44. ;
  45. EndLoop:
  46.     IF N10 NE 0 GOTO KeyGet ; If we have any fnames, stop here
  47.     IF FLAG(0) GOTO Exit    ; There are no directories
  48.     SET FLAG(0) ON        ; Mark search in COM-AND= subdir
  49.  
  50.     ENVIRON S0 "COM-AND="   ; Get COM-AND= environment variable
  51.     IF NOT FOUND GOTO Exit    ; No action if no environment variable
  52.  
  53.     LENGTH S0 N0        ; Get its length
  54.     DEC N0            ; Point to last char in string
  55.     IF NOT STRCMP S0(N0:N0) "\" S0 = S0&"\"
  56.     FFIRST S0&"*.DIR"       ; Concatenate path and name
  57.     IF FAILED GOTO Exit    ; Exit if none found
  58.     GOTO Loop
  59. ;
  60. ;    Subroutine to intercept ESCAPE
  61. ;
  62. Exit:
  63.     WCLOSE ALL        ; Restore saved screen area
  64.     STACK "^@ "             ; "^@ " -> Alt-d  (open DD after script)
  65.     EXIT            ; No window foolishness
  66. ;
  67. ;    Invalid input
  68. ;
  69. Invalid:
  70.     SOUND 100,100        ; Bronx cheer
  71. ;
  72. ;    Fetch a response
  73. ;
  74. Keyget:
  75.     KEYGET S0        ; Set for current execution
  76.     IF NOT FIND "1234567890abcdefghij" S0 N0 GOTO Invalid
  77.     IF N0 GE N10 GOTO Invalid
  78. ;
  79. ;    Load the new directory
  80. ;
  81.     LOAD DIAL S10[N0]    ; Load new directoryiable found
  82.     GOTO Exit
  83. ;
  84. ;    Open a window and display a menu
  85. ;
  86. Window:
  87.     WOPEN  0 10 16 70 (defa)
  88.     ATSAY  0 12 (default) " COM-AND Dialing directories "
  89.     ATSAY 16 30 (default) " Press ESC to cancel "
  90.  
  91.     ATSAY  2 12 (default) "1) "
  92.     ATSAY  3 12 (default) "2) "
  93.     ATSAY  4 12 (default) "3) "
  94.     ATSAY  5 12 (default) "4) "
  95.     ATSAY  6 12 (default) "5) "
  96.     ATSAY  7 12 (default) "6) "
  97.     ATSAY  8 12 (default) "7) "
  98.     ATSAY  9 12 (default) "8) "
  99.     ATSAY 10 12 (default) "9) "
  100.     ATSAY 11 12 (default) "0) "
  101.  
  102.     ATSAY  2 42 (default) "A) "
  103.     ATSAY  3 42 (default) "B) "
  104.     ATSAY  4 42 (default) "C) "
  105.     ATSAY  5 42 (default) "D) "
  106.     ATSAY  6 42 (default) "E) "
  107.     ATSAY  7 42 (default) "F) "
  108.     ATSAY  8 42 (default) "G) "
  109.     ATSAY  9 42 (default) "H) "
  110.     ATSAY 10 42 (default) "I) "
  111.     ATSAY 11 42 (default) "J) "
  112.  
  113.     S0 = "_DIRF"            ; Take current directory
  114.     UPPER S0        ; Upper case
  115.     LENGTH S0 N0        ; Take its length
  116.     IF N0 GT 46 S0 = S0(N0-46:N0-1)
  117.     ATSAY 13 12 (default) "Currently: "*S0
  118.     ATSAY 14 12 (default) "Select the directory: "
  119.     RETURN
  120.